﻿Public Class Discussion
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            GridView1.DataSource = SqlDataSource1
            GridView1.DataBind()
        End If
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bt_DiscSubmit.Click
        Dim oleDbcom As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("Phones").ConnectionString)
        oleDbcom.Open()
        Dim sqlString As String = "INSERT INTO DiscussionForum(Author,DiscussionTitle,DiscussionBody,TimePost) VALUES (@f1,@f2,@f3,@f4)"
        Dim cm As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlString, oleDbcom)
        Dim newFileName As String = Guid.NewGuid().ToString() & ".jpg"
        cm.CommandType = CommandType.Text
        cm.Parameters.AddWithValue("@f1", User.Identity.Name)
        cm.Parameters.AddWithValue("@f2", tb_DisTitle.Text)
        cm.Parameters.AddWithValue("@f3", tb_DisDesc.Text)
        cm.Parameters.AddWithValue("@f4", DateTime.Today)
        cm.ExecuteNonQuery()
        oleDbcom.Close()
        cm.Dispose()
        oleDbcom.Dispose()
        GridView1.DataSource = SqlDataSource1
        GridView1.DataBind()
        tb_DisTitle.Text = ""
        tb_DisDesc.Text = ""
        lb_Disc.Text = "Thank you for contributing to the Discussion"
    End Sub
End Class